home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 September (IDG) / Sep99.iso / Shareware World / Comms & Internet / LinkConverter 1.1.2 / Dialog Director v0.7 / Examples / ResBrowser.as < prev    next >
Encoding:
Text File  |  1998-01-19  |  1.6 KB  |  55 lines  |  [TEXT/ToyS]

  1. property ddFonts : [null, null, null, {name:"Geneva", size:10}]
  2.  
  3. dd install with fonts ddFonts with grayscale
  4. open (choose file with prompt "Choose a resource file:")
  5. dd uninstall
  6.  
  7. on open theFiles
  8.     set r1 to null
  9.     set d to null
  10.     dd install with fonts ddFonts with grayscale
  11.     try
  12.         set rFile to (theFiles as list)'s item 1
  13.         set rTypes to []
  14.         set r1 to res open rFile -- with write permission
  15.         set rCount to res count types r1
  16.         repeat with i from 1 to rCount
  17.             set rTypes to rTypes & (res get type r1 index i)
  18.         end repeat
  19.         
  20.         set d to dd make dialog {size:[280, 238], style:standard window, closeable:true, contents:[¬
  21.             {class:pop up, name:"Resource Type", bounds:[10, 5, 250, 25], contents:rTypes, font:1}, ¬
  22.             {class:list box, bounds:[-1, 55, 281, 239], column widths:[50, 170, 60], contents:ListType(r1, rTypes's item 1)}, ¬
  23.             {class:static text, contents:"ID     Name              Attributes", bounds:[4, 34, 280, 50]} ¬
  24.                 ], name:"Resources in “" & (info for rFile)'s name & "”"}
  25.         repeat
  26.             set i to dd interact with user
  27.             if i = 1 then
  28.                 dd set contents of item 2 of d to ListType(r1, rTypes's item (dd get value of item 1 of d))
  29.             else if i = -1 then
  30.                 exit repeat
  31.             end if
  32.         end repeat
  33.     on error
  34.     end try
  35.     if d ≠ null then dd delete d
  36.     if r1 ≠ null then res close r1
  37. end open
  38.  
  39. on quit
  40.     dd uninstall
  41.     continue quit
  42. end quit
  43.  
  44. on ListType(rf, rType)
  45.     set rInfos to []
  46.     try
  47.         set rCount to res count rf type rType
  48.         repeat with i from 1 to rCount
  49.             set inf to res get info rf type rType index i
  50.             set rInfos to rInfos & (((inf's res id) as text) & tab & inf's res name & tab & inf's res attributes)
  51.         end repeat
  52.     on error
  53.     end try
  54.     return rInfos
  55. end ListType